<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        .p {
            display: inline-block;
            color: skyblue;
            font-size: 14px;
        }

        .wrong {
            color: red;
        }
        .right {
            color: rgb(118, 189, 12);
        }
    </style>
</head>

<body>
    <input type="password" placeholder="请输入密码">
    <p class="p">请输入6~16位密码</p>
    <script>
        var input = document.querySelector('input');
        var p = document.querySelector('p');
        input.onblur = function () {
            if (input.value.length < 6 || input.value.length > 16) {
                p.className = 'p wrong';
                p.innerHTML = '输入不规范密码';
            } else {
                p.className = 'p right'
                p.innerHTML = '密码正确';
            }
        }
    </script>
</body>

</html>